#include "stdafx.h"
#include "RTFramework.h"
#include "RTWindowApplication.h"
#include "RTMacro.h"

INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
	RTFramework* pRTFramework = RTFramework::CreateFramework();

	if( !pRTFramework )	return 0;
	if( !pRTFramework->GetRTWinApp()->Create( hInstance ) )	return 0;
	if( !pRTFramework->CreateRenderer() )	return 0;

	pRTFramework->GameInit();

	ShowWindow( pRTFramework->GetRTWinApp()->GetHWND(), iCmdShow );
	UpdateWindow( pRTFramework->GetRTWinApp()->GetHWND() );

	MSG msg;
	ZeroMemory( &msg, sizeof(msg) );
	while( msg.message!=WM_QUIT )
	{
		if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}

		pRTFramework->Run();
	}

	RTSAFE_DELETE( pRTFramework );

	return 0;
}